package com.adcc.loadsheet.billing.entity;

import com.adcc.loadsheet.billing.util.DateTimeUtil;
import com.adcc.loadsheet.billing.util.SystemOperationLogType;
import com.adcc.loadsheet.billing.vo.SystemOperationLogEntityVO;

import java.util.Date;

/**
 * 系统操作日志表实体类
 * Created by zhaoml on 2020/9/8.
 */
public class SystemOperationLogEntity extends BasisEntity<SystemOperationLogEntityVO> {
    private String content;     //日志内容
    private String operator;    //操作者
    private Date createAt;    //操作时间
    private Integer operationType;   //操作类型

    @Override
    public SystemOperationLogEntityVO toVO() {
        SystemOperationLogEntityVO vo = new SystemOperationLogEntityVO();
        vo.setContent(this.content);
        vo.setOperator(this.operator);
        vo.setCreateAt(DateTimeUtil.toDateTimeString(this.createAt));
        vo.setOperationType(checkType(SystemOperationLogType.values()[this.operationType]));
        return vo;
    }

    private String checkType(SystemOperationLogType type) {
        switch (type) {
            case BillingRule_Operation:
                return "计费规则管理";
            case ContractUser_Operation:
                return "合同用户管理";
            case AutomaticProcessingBills_Operation:
                return "自动处理账单";
            case BillingList_Operation:
                return "计费账单查询";
            case Permission_Operation:
                return "权限管理";
            default:
                return "未知类型";
        }
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public Integer getOperationType() {
        return operationType;
    }

    public void setOperationType(Integer operationType) {
        this.operationType = operationType;
    }
}